package pt.utl.ist.project_ccu.android_libs;

import java.util.ArrayList;
import java.util.List;


public class Album {
	private String _albumName;
	private List<Tag> _tags;
	private ArrayList<Photo> _photosCache;
	private ArrayList<Photo> _photos;
	private boolean _dirty;
	
	public Album(String albumName) {
		_tags = new ArrayList<Tag>();
		_photosCache = new ArrayList<Photo>();
		_photos = new ArrayList<Photo>();
		_dirty = false;
		_albumName = albumName;
	}
	

	
	@Override
	public boolean equals(Object other){
	    if (other == null) return false;
	    if (other instanceof Album) {
	    	return ((Album) other).getAlbumName().equals(_albumName);
	    }
	    return false;
	}
	
	public void addTag(Tag tag) {
		_tags.add(tag);
	}
	
	public String getAlbumName() {
		return _albumName;
	}
	
	public void updatePhotos(List<Photo> photos) {
		_photosCache.clear();
		for (Photo p : photos) {
			if(p.hasTags(_tags)) {
				_photosCache.add(p);
			}
		}
	}
	
	public boolean isDirty() {
		return _dirty;
	}
	
	public void setDirty(boolean dirty) {
		_dirty = dirty;
	}
	
	public ArrayList<Photo> getPhotosCache() {
		return _photosCache;
	}
	
	public ArrayList<Photo> getPhotos() {
		return _photos;
	}
	
	public void addPhotos(List<Photo> list) {
		_photos.addAll(list);
	}
	
	public void addPhotos(Photo photo) {
		_photos.add(photo);
	}




	public void addTag(List<Tag> tags) {
		for (Tag t : tags) {
			_tags.add(t);
		}
		
	}
	
	public void removePhoto(Photo photo) {
		_photos.remove(photo);
	}



	public void setName(String string) {
		_albumName = string;
		
	}
	
	
	

}
